<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
	<meta charset="utf-8" />
	<meta name="keywords" content="pinpin社保" />
	<meta name="description" content="pinpin社保" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="renderer" content="webkit" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>社保运营后台-转移单管理</title>
	<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
</head>
<body>
	<div id="wrapper">
        <%@ include file="/WEB-INF/jsp/common/menu.jsp" %>
        <div id="page-wrapper">
        	<div class="row">
                <div class="col-lg-12">
                    <!-- 路径导航 -->
                    <ol class="breadcrumb">
				      <li>社保后台</li>
				      <li class="active">转移管理</li>
				    </ol>
                </div>
            </div>
            <div class="row">
            	<div class="col-lg-12">
            		<div class="panel panel-default">
            			<div class="panel-body">
        			    	<div class="form-inline dt-bootstrap no-footer">
        			    		<!-- 表单查询 -->
        			    		<form action="" method="POST" class="form-check" id="queryOrderForm">
        			    		<div class="row">
        			    			<div class="col-lg-12">
        			    				<input type="text" class="form-control" name="move_no" placeholder="订单号" value="${queryForm.move_no }"/>
        			    				<input type="text" class="form-control" name="uid" placeholder="用户手机" value="${queryForm.uid }"/>
                                        <select class="form-control" name="status">
                                            <option value="">全部状态</option>
                                            <option value="1" <c:if test="${queryForm.status eq 1 }">selected="selected"</c:if>>待付款</option>
                                            <option value="2" <c:if test="${queryForm.status eq 2 }">selected="selected"</c:if>>完成付款</option>
                                            <option value="4" <c:if test="${queryForm.status eq 4 }">selected="selected"</c:if>>办理完成</option>
                                            <option value="11" <c:if test="${queryForm.status eq 11 }">selected="selected"</c:if>>已全额退款</option>
                                        </select>
        			    				<label class="checkbox-inline" style="padding-bottom:10px">类型：
											<input type="radio" name="move_type" value="" ${empty queryForm.move_type ? 'checked' : '' }>全部</label>
        			    				<label class="checkbox-inline" style="padding-bottom:10px">
											<input type="radio" name="move_type" value="1" ${queryForm.move_type==1 ? 'checked' : '' }>社保</label>
										<label class="checkbox-inline" style="padding-bottom:10px">
											<input type="radio" name="move_type" value="2" ${queryForm.move_type==2 ? 'checked' : '' }>公积金</label><br/>
        			    				
        			    				<label class="control-label"> 转出：</label>
	                                    <c:set var="citySelectPCitys" value="${pOutCityList }" scope="request"/>
                                        <c:set var="citySelectCitys" value="${outCityList }" scope="request"/>
                                        <jsp:include page="/WEB-INF/jsp/common/citySelect.jsp">
                                        	<jsp:param name="id" value="out_city" />
                                        	<jsp:param name="name" value="out_city" />
                                        	<jsp:param name="value" value="${queryForm.out_city }" />
                                        </jsp:include>
                                        
                                        <label class="control-label"> 转入：</label>
                                        <c:set var="citySelectPCitys" value="${pIntoCityList }" scope="request"/>
                                        <c:set var="citySelectCitys" value="${intoCityList }" scope="request"/>
                                        <jsp:include page="/WEB-INF/jsp/common/citySelect.jsp">
                                        	<jsp:param name="id" value="into_city" />
                                        	<jsp:param name="name" value="into_city" />
                                        	<jsp:param name="value" value="${queryForm.into_city }" />
                                        </jsp:include><br /><br />
	                                    
        			    				<label  class="control-label">下单时间： </label>
	        			    				<input type="text" name="start_time" value="${queryForm.start_time }" placeholder="开始时间" size="12" onClick="WdatePicker()" class="form-control">
	                                        <span>-&#12288;</span>
	        			    				<input type="text" name="end_time" value="${queryForm.end_time }" placeholder="结束时间" size="12" onClick="WdatePicker()" class="form-control">
        			    			   
        			    			    <button type="submit" class="btn btn-primary">查 询</button>
        			    			    <button type="button" id="resetBtn" class="btn btn-primary">重置</button>
        			    			</div>
        			    		</div>
        			    		</form>
        			    		<!-- 分页 -->
        			    		<div class="row">
        			    		    <div class="col-lg-1">
	        			    			<button class="btn btn-primary btn-sm" id="export" onclick="javascript:exportExcel();">导出为EXCEL</button>
        			    			</div>
        			    			<div class="col-lg-1">
        			    			</div>
        			    			<div class="col-lg-10">
        			    				<jsp:include page="/WEB-INF/jsp/common/page.jsp">
        			    					<jsp:param name="formId" value="queryOrderForm"/>
        			    				</jsp:include>
        			    			</div>
        			    		</div>
        			    		<!-- 表格列表 -->
        			    		<div class="row">
        			    			<div class="col-lg-12 width-auto">
        			    				<table id="dataContent" class="table table-striped table-bordered table-hover no-footer" role="grid">
        			    					<thead>
        			    						<tr><th title="全选"><label><input type="checkbox" id="pids" name="pids" >全选</label></th>
                                                    <th>转移类型</th>
                                                    <th>用户 </th>
                                                    <th>转出城市</th>
                                                    <th>转入城市</th>
                                                    <th>金额</th>
                                                    <th>实付</th>
                                                    <th>用券</th>
                                                    <th>状态</th>
                                                    <th>操作</th>
                                                    <th>运营备注</th>
                                                    <th>时间</th>
                                                    <th>用户说明</th>
                                                    <th>支付相关</th>
                                                </tr>
        			    					</thead>
        			    					<tbody>
                                            <c:choose>
       			    						<c:when test="${empty pageModel.recordList }">
       			    							没有找到相关记录啊
       			    						</c:when>
       			    						<c:otherwise>
        			    					<c:forEach items="${pageModel.recordList }" var="order">
        			    					<tr role="row">
        			    							<td><input type="checkbox" id="pids_${order.move_no }" name="pids" value="${order.move_no }"></td>
                                                    <td style="text-align:right">${order.type_name }</td>
                                                    <td style="text-align:right"> ${order.user_name } &nbsp;&nbsp; ${order.phone }</td>
                                                    <td>${order.out_cname }</td>
                                                    <td>${order.into_cname }</td>
													<td style="text-align:right">${order.total_charge }</td>
													<td>￥${order.actual_charge }</td>
													<td>
														<c:if test="${not empty order.couponuser_id}">用券 ${order.couponuser_price }</c:if>
													</td>
                                                    <td>
                                                    	<c:if test="${order.status == 1 }">待付款</c:if>
                                                    	<c:if test="${order.status == 2 }">完成付款</c:if>
                                                    	<c:if test="${order.status == 4 }">完成办理</c:if>
                                                    	<c:if test="${order.status == 11 }">已全额退款</c:if>
													</td>
                                                    <td>
                                                    	<a href="javascript:showNotesBox('${order.move_no }');">备注</a> 
                                                    	<c:if test="${order.status == 2 }">
	                                                    	<a href="javascript:showRefundBox('${order.move_no }');">退款</a>
	                                                    	<a href="javascript:showSuccessBox('${order.move_no }');" id="btnSuccess">完成</a>
                                                    	</c:if>
                                                    </td>
                                                    <td>${order.notes } </td>
                                                    <td>${order.gen_time } </td>
													<td>${order.remark }</td>
													<td style="text-align: left">
                                                   		${order.move_no }&nbsp;&nbsp;
                                            			${order.pay_channel == 1 ? '微信支付  ' : '支付宝支付  '} &nbsp;&nbsp;
                                                    	支付流水号：${order.pay_no }&nbsp;&nbsp;
													</td>
        			    						</tr>
        			    					</c:forEach>
		        			    						</c:otherwise>
		        			    					</c:choose>

        			    					</tbody>
        			    				</table>
        			    				
        			    			</div>
        			    		</div>
        			    		<!-- 分页 -->
        			    		<div class="row">
        			    			<div class="col-lg-2">
        			    			</div>
        			    			<div class="col-lg-10">
        			    				<jsp:include page="/WEB-INF/jsp/common/page.jsp">
        			    					<jsp:param name="formId" value="queryOrderForm"/>
        			    				</jsp:include>
        			    			</div>
        			    		</div>
        			    		
        			    	</div>
            			</div>
            		</div>
            	</div>
            </div>
        </div>
	</div>
	
<div id="noteBox" style="display:none;width:360px">
	<form name="notesForm" id="notesForm" method="post">
		<input type="text" class="form-control" id="notes" name="notes">
		<input type="hidden" class="form-control" id="move_no" name="move_no">
		<br>
		<button type="button" class="btn btn-primary btn-sm" onclick="javascript:saveNote()">提交备注</button>
	</form>
</div>
<div id="successBox" style="display:none;width:360px">
	<form name="successBoxForm" id="successBoxForm" method="post">
		<textarea class="form-control" id="notes" name="notes"  placeholder="顺便写个备注咯  (可不写)" ></textarea>
		<input type="hidden" class="form-control" id="success_move_no" name="move_no">
		<br>
		<button type="button" class="btn btn-primary btn-sm" onclick="javascript:saveSuccess()">确定转移完成</button>
	</form>
</div>


<div id="refundBox" style="display:none;width:260px">
	<form name="refundForm" id="refundForm" method="post">
		<input type="text" class="form-control" id="refund_notes" name="notes">
		<input type="hidden" class="form-control" id="refund_move_no" name="move_no">
		<button type="button" class="btn btn-primary btn-sm" onclick="javascript:refund()">确定退款</button>
	</form>
</div>

</body>
    <script language="javascript">
    var note_uri = "${note_uri}";
    var success_uri = "${success_uri}";
    var export_uri = "${export_uri}";
    var refund_uri = "${refund_uri}";
    $(function() {
    	$("#resetBtn").click(function(){
    		$("#queryOrderForm").find("input[type=text],select").filter(function(index) {
				  return $(this).attr("dataType") != "city_select";
			}).val("");
    	});
    });

    function showNotesBox(move_no) {
 	   $("#move_no").val(move_no);
       var content=document.getElementById("noteBox");
       dialog({
     	  title: '备注 ',
     	  content: content,
     	  follow: document.getElementById("btnNote"),
     	  quickClose:true}).show();
    }
    function saveNote() {
 	    var data = $("#notesForm").serialize();
 	    $.post(note_uri, data, function(result, textStatus){
 		    alert(textStatus);
 		    jsonResult(result);
 	    });
    }

    function showRefundBox(move_no) {
 	   $("#refund_move_no").val(move_no);
       var content=document.getElementById("refundBox");
       dialog({
     	  title: ' 全部退款 ',
     	  content: content,
     	  follow: document.getElementById("btnRefund"),
     	  quickClose:true}).show();
    }
    function refund() {
 	    var data = $("#refundForm").serialize();
 	    $.post(refund_uri, data, function(result, textStatus){
 		    jsonResult(result);
 	    });
    }
    
    function jsonResult(result) {
	    smokeAlert(result.code, result.msg);
	    if (result.code == 200) {
		    window.location.reload();
	    }
    }
    
    function showSuccessBox(move_no) {
  	   $("#success_move_no").val(move_no);
        var content=document.getElementById("successBox");
        dialog({
      	  title: '完成 ',
      	  content: content,
      	  follow: document.getElementById("btnSuccess"),
      	  quickClose:true}).show();
     }
    function saveSuccess() {
 	    var data = $("#successBoxForm").serialize();
 	    $.post(success_uri, data, function(result, textStatus){
 		    jsonResult(result);
 	    });
    }
    

    function exportExcel() {
 	    var data = $("#queryOrderForm").serialize();
 	    var inputs = '';
        jQuery.each(data.split('&'), function(){ 
        	var pair = this.split('=');
            inputs+='<input type="hidden" name="'+ pair[0] +'" value="'+ pair[1] +'" />'; 
        });
        // request发送请求
        jQuery('<form action="'+export_uri+'" method="post">'+inputs+'</form>')
        	.appendTo('body').submit().remove();
    }
    
    </script>
</html>